package com.pkk.cloud.support.admin.utils;

import com.pkk.cloud.support.admin.bo.ClientSecurityHandleBo;
import com.pkk.cloud.support.oauth2.common.utils.UserInfoUtil;
import com.pkk.components.encryption.util.Base64;

/**
 * @description:客户端加密操作的工具类
 * @author: peikunkun
 * @create: 2020-03-30 11:17
 **/
public class ClientSecurityUtil {


  /**
   * @Description: 密码加密操作
   * @Param: pwd:原密码
   * @return: com.pkk.cloud.support.admin.bo.ClientSecurityHandleBo
   * @Author: peikunkun
   * @Date: 2020/3/30 0030 上午 11:18
   */
  public static ClientSecurityHandleBo bCryptPassword(String clientId, String pwd) {
    final String encrypt = UserInfoUtil.encrypt(pwd);
    return ClientSecurityHandleBo.builder()
        .clientSecret(encrypt)
        .clientCode(Base64.encode((clientId + ":" + encrypt).getBytes()))
        .clientBasic(Base64.encode((clientId + ":" + pwd).getBytes()))
        .build();
  }

}
